//
//  UINavigationController+LiDaPush.m
//  HDTransitonDemo
//
//  Created by mac on 2017/6/7.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UINavigationController+LiDaPush.h"
#define Duration 0.5
@implementation UINavigationController (LiDaPush)

- (void)LiDa_PushViewControlle:(UIViewController *)viewController
            WithAnimationType:(NSString *)type
                  WithSubtype:(NSString *)subType{
    
    CATransition *animation = [self trasitonWithType:type withSubtype:subType];
    [self.view.layer addAnimation:animation forKey:@"kTransitionAnimation"];
    [self pushViewController:viewController animated:NO];
}

- (void)LiDa_PopWithAnimationType:(NSString *)type
                     WithSubtype:(NSString *)subType{
    
    CATransition *animation = [self trasitonWithType:type withSubtype:subType];
    [self.view.layer addAnimation:animation forKey:@"kPopTransitionAnimation"];
    [self popViewControllerAnimated:NO];
}

/*****present dismiss***********/
- (void)LiDa_PresentViewControlle:(UIViewController *)viewController
               WithAnimationType:(NSString *)type
                     WithSubtype:(NSString *)subType{
    CATransition *animation = [self trasitonWithType:type withSubtype:subType];
    [self.view.window.layer addAnimation:animation forKey:@"kPresentTransitionAnimation"];
    [self presentViewController:viewController animated:YES completion:^{
        
    }];
}

- (void)LiDa_DissWithAnimationType:(NSString *)type
                      WithSubtype:(NSString *)subType{
    CATransition *animation = [self trasitonWithType:type withSubtype:nil];
    [self.view.window.layer addAnimation:animation forKey:@"kDisMissTransitionAnimation"];
    [self.visibleViewController dismissViewControllerAnimated:YES completion:^{
        
    }];
}



- (CATransition *)trasitonWithType:(NSString *)type withSubtype:(NSString *)subType{
    CATransition *animation = [CATransition animation];
    animation.duration = Duration;
    animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
    animation.type = type;
    animation.subtype = subType;
    return animation;
}

@end
